Improve XendCheckpoint's forkHelper error handling.
authorBrendan Cully <brendan@cs.ubc.ca>
Thu, 14 Dec 2006 01:45:50 +0000 (17:45 -0800)
committerBrendan Cully <brendan@cs.ubc.ca>
Thu, 14 Dec 2006 01:45:50 +0000 (17:45 -0800)
When inputHandler raises an exception, close stdin and stdout in the
child before attempting to close stderr, which is held open by a
separate thread. Without this patch, exceptions raised by device
migration caused xend to hang on child.childerr.close().

Signed-off-by: Brendan Cully <brendan@cs.ubc.ca>
tools/python/xen/xend/XendCheckpoint.py

index 21a323cdccfc86d847b603e643f593ca54caa9be..85a59e5d224e85ba3e003ea82f6a8a0103f95b18 100644 (file)
@@ -218,18 +218,17 @@ def forkHelper(cmd, fd, inputHandler, closeToChild):
                     log.debug('%s', line)
                     inputHandler(line, child.tochild)
 
-            thread.join()
-
         except IOError, exn:
             raise XendError('Error reading from child process for %s: %s' %
                             (cmd, exn))
     finally:
         child.fromchild.close()
-        child.childerr.close()
         if not closeToChild:
             child.tochild.close()
+        thread.join()
+        child.childerr.close()
+        status = child.wait()
 
-    status = child.wait()
     if status >> 8 == 127:
         raise XendError("%s failed: popen failed" % string.join(cmd))
     elif status != 0: